import request from '../util/request'
import {KEY,API_24,API_7D,API_GEO_CITY,API_NOW, API_AIR,API_INDICES,API_INDICES_3day} from './urlAPI';
//未来24小时天气预报请求

const fetch24HourData = function(locationID){
    return request.get(API_24,{
        params:{
            location: locationID,
            key: KEY,
        }
    })
}

//未来7日天气预报请求

const fetch7DayData = function(locationID){
    return request.get(API_7D,{
        params:{
            location: locationID,
            key: KEY,
        }
    })
}

const fetchCityData = function(cityName){
    return request.get(API_GEO_CITY,{
        params:{
            location: cityName,
            key: KEY,
        }
    })
}

const fetchNowWeatherData = function(locationID){
    return request.get(API_NOW,{
        params:{
            location: locationID,
            key:KEY,
        }
    })
}

const fetchAirData=function(locationID){
    return request.get(API_AIR,{
        params:{
            location:locationID,
            key:KEY,
        }
    })
}

const fetchIndicesData=(locationID,type)=>{
    return request.get(API_INDICES,{
        params:{
            location:locationID,
            type:type,
            key:KEY,
        }
    })
}

const fetchIndicesData3day=(locationID,type)=>{
    return request.get(API_INDICES_3day,{
        params:{
            location:locationID,
            type:type,
            key:KEY,
        }
    })
}
export {fetch24HourData,fetch7DayData,fetchCityData,fetchNowWeatherData,fetchAirData,fetchIndicesData,fetchIndicesData3day}